<?php
namespace app\common\model;

use think\Model;
use think\model\concern\SoftDelete;

class Article extends Model
{
    use SoftDelete;
    protected $autoWriteTimestamp = true;
    protected $createTime = "add_time";
    protected $updateTime ="last_time";
    public function getAddTimeAttr($value)
    {
        return date("Y-m-d",$value);
    }
    public function user()
    {
        return $this->hasOne(User::class,"id","uid");
    }

    public function cate()
    {
        return $this->hasOne(ArticleCate::class,"id","cate_id");
    }
    public function log()
    {
        return $this->hasMany(ArticlePv::class,"aid","id")->order('id DESC')->limit(10);
    }

    public function content()
    {
        return $this->hasOne(Content::class,"id","contentid");
    }
}
